<?php 
namespace lib;
class Order_Template{
    protected $conf;
    protected $httphost;
    public function __construct($conf = null){
       $this->conf = $conf;
       $this->httphost = $this->conf->localurl;
    }
    public function send($scene,$data , $title){
       if(method_exists($this, $scene)) {
           return $this->$scene($data, $title);
       }
       return false;
    }
    public function Cyber($data,$title){
        if(empty($data['paragraphs'])){
            return false;
        }
        $order = $this->Cybet_table($data['paragraphs']);
        $currentYear = date("Y");
        $msg = <<<HTML
            <!DOCTYPE html>
            <html lang="zh-CN">
            <head>
                <meta charset="UTF-8">
                <meta name="viewport" content="width=device-width, initial-scale=1.0">
                <title>{$this->conf->sitename}-{$title}</title>
            </head>
            <body style="font-family: 'Roboto', sans-serif; background-color: #0d0d0d; margin: 0; padding: 20px; color: #e0e0e0;">
            <div style="max-width: 600px; margin: 0 auto; background-color: #1a1a1a; border: 2px solid #3a3a3a; border-radius: 10px; padding: 20px; box-shadow: 0 0 15px rgba(0, 255, 255, 0.5);">
            <div style="text-align: center; margin-bottom: 20px;">
                <img src="{$this->httphost}/assets/img/logo.png" alt="Logo" style="width: 30%; height: auto; border-radius: 5px;">
            </div>
            <h2 style="font-size: 24px; color: #00ffff; margin-bottom: 20px; font-weight: bold; text-shadow: 0 0 8px #00ffff;">{$this->conf->sitename}{$title}</h2>
            <p style="font-size: 16px; color: #e0e0e0; margin-bottom: 10px;">尊敬的 <strong style="color: #00ffff;">{$data['user']}</strong> ，您好！</p>
            <p style="font-size: 16px; color: #e0e0e0; margin-bottom: 20px;">您的新订单情况如下：</p>
            <div style="background-color: #1f1f1f; padding: 15px; border-radius: 8px; margin-bottom: 20px; border: 1px solid #333;">
                <table style="width: 100%; font-size: 15px; color: #e0e0e0;">
                    {$order}
                </table>
            </div>
            <a href="{$this->httphost}" style="display: block; background: linear-gradient(to right, #00ffff, #ff00ff); color: white; padding: 12px 0; border-radius: 4px; text-decoration: none; font-size: 16px; font-weight: bold; text-align: center; width: 100%; box-sizing: border-box; box-shadow: 0 0 10px #00ffff, 0 0 10px #ff00ff; transition: background 0.3s ease;">
                前往支付站点
            </a>
            <p style="font-size: 14px; color: #666; margin-top: 20px;">此致<br><strong style="color: #00ffff;">{$this->conf['sitename']}</strong></p>
            <p style="font-size: 12px; color: #888; margin-top: 30px; text-align: center;">此为系统邮件，请勿回复。</p>
            <p style="font-size: 12px; color: #888; margin-top: 10px; text-align: center;">Copyright © {$currentYear} {$this->conf['sitename']} All rights reserved</p>
            </div>
            </body>
            </html>
HTML;
        return $msg;
    }
    
    protected  function Cybet_table($data){
        $paragraphs = '';
        foreach ($data as $item) {
            $label = $item['label'];
            $value = $item['value'];
            $paragraphs .= "<tr>
                <td style=\"padding: 8px 0; border-bottom: 1px solid #444;\">{$label}</td>
                <td style=\"padding: 8px 0; border-bottom: 1px solid #444; text-align: right;\"><strong style=\"color: #ff00ff;\">{$value}</strong></td>
            </tr>";
        }
        return $paragraphs;
    }
   
    public function lovable($data , $title){
        $order = $this->lovable_table($data['paragraphs']);
        $currentYear = date("Y");
        $msg = <<<HTML
            <!DOCTYPE html>
            <html lang="zh-CN">
                <head>
                    <meta charset="UTF-8">
                    <meta name="viewport" content="width=device-width, initial-scale=1.0">
                    <title>{$this->conf['sitename']}-{$title}</title>
                </head>
                <body style="font-family: 'Arial', sans-serif; background-color: #f8e8e8; margin: 0; padding: 20px;">
                <div style="max-width: 600px; margin: 0 auto; background-color: #ffffff; border: 2px solid #ffc0cb; border-radius: 12px; padding: 20px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);">
                <div style="text-align: center; margin-bottom: 20px;">
                    <img src="{$this->httphost}/assets/img/logo.png" alt="{$conf['sitename']} Logo" style="width: 30%; height: auto; border-radius: 8px;">
                </div>
                <h2 style="font-size: 22px; color: #ff69b4; margin-bottom: 20px; font-weight: bold;">【{$this->conf['sitename']}】{$title}</h2>
                <p style="font-size: 16px; color: #333; margin-bottom: 10px;">尊敬的 <strong style="color: #ff69b4;">{$data['user']}</strong> ，您好！</p>
                <p style="font-size: 16px; color: #333; margin-bottom: 20px;">您的新订单情况如下：</p>
                <div style="background-color: #fff0f5; padding: 15px; border-radius: 10px; margin-bottom: 20px;">
                    <table style="width: 100%; font-size: 15px; color: #333;">
                        {$order}
                    </table>
                </div>
                <a href="{$this->httphost}/" style="display: block; background: linear-gradient(to right, #ff7f7f, #ff69b4); color: white; padding: 12px 0; border-radius: 25px; text-decoration: none; font-size: 16px; font-weight: bold; box-shadow: 0 4px 8px rgba(255, 105, 180, 0.4); transition: background 0.3s ease; text-align: center; width: 100%; box-sizing: border-box;">
                    前往商户中心
                </a>
                <p style="font-size: 14px; color: #666; margin-top: 20px;">此致<br><strong style="color: #ff69b4;">{$this->conf['sitename']}</strong></p>
                <p style="font-size: 12px; color: #aaa; margin-top: 30px; text-align: center;">此为系统邮件，请勿回复。</p>
                <p style="font-size: 12px; color: #aaa; margin-top: 10px; text-align: center;">Copyright © {$currentYear} {$this->conf['sitename']} All rights reserved</p>
                </div>
                </body>
            </html>
HTML;
        return $msg;
    }
    protected  function lovable_table($data){
        $paragraphs = '';
        foreach ($data as $item) {
            $label = $item['label'];
            $value = $item['value'];
            $paragraphs .= "<tr>
                <td style=\"padding: 8px 0; border-bottom: 1px solid #ffc0cb;\">{$label}</td>
                <td style=\"padding: 8px 0; border-bottom: 1px solid #ffc0cb; text-align: right;\"><strong>{$value}</strong></td>
            </tr>";
        }
        return $paragraphs;
    }
}


?>